//UserServiceImpl.java
package com.ylaihui.service.impl;

import com.ylaihui.dao.UserDao;
import com.ylaihui.dao.impl.UserDaoImpl;
import com.ylaihui.pojo.User;
import com.ylaihui.service.UserService;

public class UserServiceImpl implements UserService {

    UserDao userdao = new UserDaoImpl();
    @Override
    public void registUser(User user) {
        int i = userdao.saveUser(user);
    }

    @Override
    public User login(User user) {
        User user1 = userdao.queryUserByUsernameAndPassword(user.getUsername(), user.getPassword());
        return user1;
    }

    @Override
    public boolean existsUsername(String username) {
        User user = userdao.queryUserByUsername(username);
        if (user == null)
            return false;
        else
            return true;
    }
}
